package com.hframe.plugin.amr;

import org.apache.log4j.Logger;

/**
 * 手机录音文件 转换类
 * 
 * @author heqian
 *
 */
public class AmrCoding {
	private static Logger log = Logger.getLogger(AmrCoding.class);
	private String path = "AmrToWav_linux_X86_64";

	public AmrCoding(String execPath) {
		path = execPath + path;
	}

	/**
	 * 将amr文件转换为 wav 文件
	 * 
	 * @param amrfile
	 *            输入 amr文件 @param wavfile 输出 wav文件 @return 返回真假（true, false）
	 *            是否输出成功 @throws IOException @throws
	 */
	public boolean toWav(String amrfile, String wavfile) {
		try {
			String[] cmd = { this.path, amrfile, wavfile };
			Process pro = Runtime.getRuntime().exec(cmd);
			
			pro.waitFor();

			return 0 == pro.exitValue();
		} catch (Exception e) {
			log.error(e, e);
		}
		return false;
	}

}
